/*
 * @Author: liuzelin
 * @Date: 2024-04-21 20:10:56
 * @LastEditors: liuzelin
 * @LastEditTime: 2024-04-21 20:40:21
 * @Description: file content
 */
#include "panda_uv_handler.hpp"
#include "panda_uv_helper.hpp"

#include "uv.h"

using namespace PandaImpl;
UVHandler::~UVHandler() {
  if (isClosed == false) {
    if (isClosing == false) {
      Close();
    }
    while (isClosed == false) {
    }
  }
}

void UVHandler::Close() {
  if (this->isClosed || this->isClosing ||
      uv_is_closing((uv_handle_t *)this->handler))
    return;
  uv_close((uv_handle_t *)&this->handler, &UVHelper::UVCloseCb);
  this->isClosing = true;
}